﻿import VTitle from '@/components/common/MainTitle.vue'
import ShowFormMenuLayout from '@/components/DynamicFormComponents_v2/ShowDynamicForm.vue'
// 引入公共的基础部分
import ExtendDynamicForm from '@/components/extendComponents/ExtendDynamicForm.vue'
export default {
  extends: ExtendDynamicForm,
  data () {
    return {
      dynamicUid: '',
      titleName: '',
      pageSettings: '',
      parentModel: '',
      parentPageTitle: '',
      showBack: false
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      this.pageSettings = ''
      this.titleName = ''
      this.dynamicUid = this.$route.query.uid
      if (this.$route.query.parentModel) {
        this.parentModel = JSON.parse(this.$Base64.decode(this.$route.query.parentModel))
        this.showBack = true
        this.parentPageTitle = this.$route.query.parentTitle
      } else {
        this.showBack = false
      }
      this.getFunInfo(this.dynamicUid)
    },
    // 获取功能的设定信息---定义好表头及功能的基本信息
    getFunInfo (uid) {
      this.$api.query('/d_form/' + uid).then(data => {
        this.titleName = data.name
        this.pageSettings = JSON.parse(data.settings)
      })
    },
    // 刷新当前页面
    reloadCurrentPage () {
      this.init()
    },
    goBack () {
      this.$router.back()
    }
  },
  watch: {
    // 监听路由的变化
    '$route': {
      handler: function (val, oldVal) {
        if (this.$route.path === '/dashboard/dynamicMenu_v2') {
          this.init()
        }
      }
    }
  },
  components: {
    VTitle, ShowFormMenuLayout
  }
}
